var pageNum=1;//当前页
var pageSize=5;//页容量
var total=0;//总条数
var pages=0;//总页数


function showInfo() {
    let positionName=$("#positionName").val()
    let positionSort=$("#positionSort option:selected").val()
    let registranTime=$("#registranTime").val()
    let expirationDate=$("#expirationDate").val()
    console.log(positionName);
    console.log(positionSort);
    console.log(registranTime);
    console.log(expirationDate);
    console.log(pageNum);
    console.log(pageSize)

    let jsonA={
        'positionName':positionName,
        'positionSort':positionSort,
        'registranTime':registranTime,
        'expirationDate':expirationDate,
        'pageNum':pageNum,
        'pageSize':pageSize
    }

    $.ajaxSettings.async = false;
    $.get('show',jsonA,function (dataA) {
        console.log(dataA)
        let title="<tr><th>职位编码</th><th>职位名称</th><th>职位分类</th><th>所属部门</th><th>招聘人数</th><th>登记日期</th><th>截止日期</th><th>操作</th></tr>";
        $("#positionData").html('').append(title)
        console.log(dataA.list)
        var da=dataA.list
        $(da).each(function () {
            var str="<tr>\n" +
                "                <td>"+this.positionId+"</td>\n" +
                "                <td>"+this.positionName+"</td>\n" +
                "                <td>"+this.positionSort+"</td>\n" +
                "                <td>"+this.department+"</td>\n" +
                "                <td>"+this.numbers+"</td>\n" +
                "                <td>"+this.registranTime+"</td>\n" +
                "                <td>"+this.expirationDate+"</td>\n" +
                "                <td><a href=\"#\">变更</a>&nbsp;&nbsp;<a href=\"\">明细</a>&nbsp;&nbsp;<a href=\"\">删除</a></td>\n" +
                "            </tr>"
            $("#positionData").append(str)
        })
        pages=dataA.pages;
    },'json')
    $.ajaxSettings.async = true;
}

// 上一页
function prv() {
    pageNum--;
    if (pageNum < 1) {
        pageNum = 1;
        return;
    }
    showInfo();
}
// 首页
function first() {
    pageNum = 1
    showInfo();
}
// 尾页
function last() {
    pageNum = pages;
    showInfo();
}


function next(){
    pageNum++;
    if (pageNum > pages) {
        pageNum = pages;
        return;
    }
    showInfo();
}

function goPosition() {
    location.href="/getDepartment"
}